package com.wngz.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.wngz.dto.EmployeeDto;
import com.wngz.entity.Employee;
import com.wngz.service.EmployeeService;
import com.wngz.utils.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;
import java.util.Objects;

@RestController
@RequestMapping("/employee")
public class EmployeeController {

    @Autowired
    private EmployeeService employeeService;


    @PostMapping("/query")
    public ResponseResult query(@RequestBody EmployeeDto employeeDto){
        System.out.println("employeeDto = " + employeeDto);
        IPage<Employee> employeeIPage = employeeService.queryEmployees(employeeDto);
        return ResponseResult.success(employeeIPage);
    }


    @PostMapping("/update")
    public ResponseResult updateEmployee(@RequestBody Employee employee) {
        employeeService.update(employee);
        return ResponseResult.success();
    }
}
